package com.woniu.micropropertyserver.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.microcommonsserver.entity.PassCarCheckEntity;
import com.woniu.micropropertyserver.bean.DeployParkCCheck;
import com.woniu.micropropertyserver.service.IPassCarCheckService;
import com.woniu.micropropertyserver.util.PageRest;
import com.woniu.micropropertyserver.util.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：bb
 * @date ：Created in 2021/2/2 0002
 * @description：
 * @modified By：
 * @version: $
 */
@RequestMapping("/passCarR")
@RestController
public class PassCarCheckController {
    @Autowired
    private IPassCarCheckService passCarCheckServiceImpl;

    @GetMapping(value = "/findByParams",produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultMsg findByParam(PageRest pageRest, DeployParkCCheck deployParkCCheck){
        System.out.println(deployParkCCheck);
        PageInfo<DeployParkCCheck> info = passCarCheckServiceImpl.findByParam(pageRest,deployParkCCheck);
        return  new ResultMsg(200,"操作成功",info);
    }

    @PostMapping(value = "/save",produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultMsg saveInfo(@RequestBody DeployParkCCheck deployParkCCheck){

        System.out.println(deployParkCCheck);
        int res= passCarCheckServiceImpl.saveInfo(deployParkCCheck);

        if(res >0){

            return  new ResultMsg(200,"操作成功",null);

        }else{
            return  new ResultMsg(200,"删除失败",null);
        }
    }
    @GetMapping(value = "/findByCarNum",produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultMsg findByNum(String carNum){
        System.out.println(carNum);
        DeployParkCCheck check =passCarCheckServiceImpl.findByCarNum(carNum);
        return  new ResultMsg(200,"操作成功",check);

    }
    @PutMapping(value = "/update",produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultMsg updateInfo(@RequestBody DeployParkCCheck deployParkCCheck){
        System.out.println(deployParkCCheck);
       int check =passCarCheckServiceImpl.updateInfo(deployParkCCheck);
        if(check >0){

            return  new ResultMsg(200,"操作成功",null);

        }else{
            return  new ResultMsg(200,"更新失败",null);
        }

    }
    @DeleteMapping(value = "cancel",produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultMsg cancelInfo(Long id){
        int res = passCarCheckServiceImpl.cancelInfo(id);
        if(res >0){
            return  new ResultMsg(200,"操作成功",null);

        }else{
            return  new ResultMsg(200,"删除失败",null);
        }
    }
}
